efform_onload = function ()
{

};  

button_query_onclick = function (){
	efgrid.submitInqu( "ef_grid_result", "ZM","ZMCN01","query");
}

button_update_onclick = function() {
//	efgrid.submitForm("ef_grid_result", "ZM", "ZMCN01", "update", true);
	if (isSelected("ef_grid_result") == 0)return; 
	var grid = efgrid.getGridObject("ef_grid_result");
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行修改！"); return;
		}

	}
	var info = getSCZXEiInfos("ZMCN01","ef_grid_result");//ZMCN10 为EFFORM id，ef_grid_r为grid id（paintId）
	if (null != info) { 
		EiCommunicator.send("ZMCN01", "validate", info, validate_callback);
	}
}
button_insert_onclick = function() {
//	efgrid.submitForm("ef_grid_result", "ZM", "ZMCN01", "insert", true);
	if (isSelected("ef_grid_result") == 0)return; 
	var info = getSCZXEiInfos("ZMCN01","ef_grid_result");//ZMCN10 为EFFORM id，ef_grid_r为grid id（paintId）
	if (null != info) { 
		EiCommunicator.send("ZMCN01", "validate", info, validate_callback);
	}
}

button_delete_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行删除！"); return;
		}

	}
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM","ZMCN01","delete",true);
	});
}
button_report_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行上报！"); return;
		}

	}
	EFConfirm('你确认要上报吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM","ZMCN01","report",true);
	});
}
efgrid_afterAddNewRow = function(grid_id){ 
	var grid = efgrid.getGridObject(grid_id);
	var rows = grid.getCheckedRows();
	if(grid_id=="ef_grid_result")
	{
		for(var i = 0 ; i < rows.length;i++){
			grid.getBlockData().setCell(rows[i], "fdStatus", "草拟");
			grid.getBlockData().setCell(rows[i], "fdKeyId", "");
		}
	}
}
var validate_callback={
		onSuccess:function(eiInfo){
			if(eiInfo.getStatus()==-1){
				EFAlert("操作失败，原因："+eiInfo.getMsg());
			}else{
				var oper="insert";
				if(eiInfo.get("efCurButtonEname")=="UPDATE"){
					oper="update";
				}
				efgrid.submitForm("ef_grid_result", "ZM", "ZMCN01", oper, true);
			}
		},
		onFail:function(eMsg)
		{
			EFAlert("操作失败，原因："+eMsg); 
		}
}